﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace Autenticazione.BusinessObject
{
    public class Cintura
    {
        public int Id;
        public string Belt;

        public Cintura()
        {
        }

        public Cintura(int id, string belt)
        {
            this.Id = id;
            this.Belt = belt;
        }

        public DataTable GetTbBelts()
        {
            string strSQL = string.Format(@"select * from Belt order by Id");
            DB.DB db = new DB.DB();

            return db.GetTable(strSQL);

        }

        public string GetBeltDescription()
        {
            SqlDataReader dr = null;
            string description = string.Empty;
            string strSQL = string.Format(@"select * from Belt where Id = {0}", this.Id.ToString());
            DB.DB db = new DB.DB();

            dr = db.Reader(strSQL);

            if (dr == null)
                description = string.Empty;
            
            if (dr.Read())
                description = dr["Belt"].ToString();

            db.CloseConnection();

            return description;
        }
    }
}